home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
examples
/
programs
/
proto_multi.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
5KB
|
167 lines
#ifndef lint
static char SccsId[]= "@(#)proto_multi.c V1.11 3/13/95";
#endif
/*
| file name - proto_multi.c
|===================================================================
|
| This program demostrates how to invoke two prototype from
| DV-Tools. Each prototype runs in its own window, however
| you could have change the example to have one window with
| two prototype areas. You could also expand this program by
| adding additional DV-Tools calls for activities in a third window.
|
| Each prototype enviroment gets a top view, a screen and
| drawport attributes. In this example we set the drawport
| attributes so the whole view is stretched into the whole
| screen. Each prototype as its own set of views even though
| each window is using the same views.
|
| This example shows you how you would gather you own events,
| process the window events and then call TprotoHandleInput.
| Even though TprotoHandleInput will process window events
| its better to do it yourself if you plan to integrate
| a prototype with another DV-Tools application.
|
| The program will QUIT if you select "QUIT" from either
| prototype or QUIT either window.
|
|===================================================================
*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "dvGR.h"
#include "GRfundecl.h"
#include "GRkeysym.h"
#include "Tfundecl.h"
#include "VOfundecl.h"
/* Include the function stubs need to make the executable smaller.
| Proto routines normally link in DV-Draw code, these stubs will
| avoid this.
*/
#include "protostubs.h"
#define MAXWINS 2
char *view_name[MAXWINS] = {"pix1.v", "pix2.v"};
LOCAL RECTANGLE whole_world = {XMIN, YMIN, XMAX, YMAX};
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
/* argv[1] - display device (default is DVDEVICE) */
OBJECT screen[MAXWINS], current_screen;
PROTO_ENV proto_env[MAXWINS];
DRAWPORT_ATTRIBUTES dp_atts;
OBJECT location;
int i, quit_status = NO;
char *device = NULL;
int argc;
char **argv;
make_argv(&argc,&argv,GetCommandLine());
/*
* Initialize DV-Tools using the default DVconfig path
*/
TInit ((char *) NULL, (char *) NULL);
/*
* Open a screen for each view specified on the command line, draw the
* view, enable events in the screen, and set the cursor.
*/
if (argc > 1)
device = argv[1];
for (i = 0; i < MAXWINS; i++)
{
/* Create the windows and step up polling */
screen[i] = TscOpenSet (device, (char *)NULL,
V_WINDOW_WIDTH, 350,
V_WINDOW_HEIGHT, 350,
V_WINDOW_NAME, "proto_multi",
V_WINDOW_X, 20 + 350 * i,
V_WINDOW_Y, 20,
V_X_EXPOSURE_BLOCK, YES,
V_END_OF_LIST);
TscErase (screen[i]);
VOscWinEventMask ((ULONG) V_KEYPRESS | V_BUTTONPRESS | V_MOTIONNOTIFY |
V_EXPOSE | V_RESIZE | V_WINDOW_QUIT,
0L);
/* Initialize the prototype environment. this will display
| the "whole" top view in a stretch drawport taking up
| the "whole" screen/window.
*/
dp_atts.vvp = NULL;
dp_atts.wvp = &whole_world;
dp_atts.stretch_flag = (DV_BOOL) YES;
/* TprotoInit() will return NULL if the view_name couldn't be loaded */
proto_env[i] = (PROTO_ENV) TprotoInit (screen[i], view_name[i], &dp_atts);
}
/*
* Main event loop. Get the next location object, determine which
* screen it came from and set the current screen to that screen,
* then switch on the location object's type.
*/
FOREVER
{
/* Handle Event */
location = VOloWinEventPoll ((int)V_NO_WAIT);
if (location)
{
current_screen = VOloScreen (location);
if (current_screen)
VOscSelect (current_screen);
i = (current_screen == screen[0]) ? 0 : 1;
switch (VOloType (location))
{
case V_EXPOSE:
TprotoRedraw (proto_env[i]);
break;
case V_RESIZE:
TprotoReset (proto_env[i]);
break;
case V_WINDOW_QUIT:
quit_status = YES;
break;
default:
if (TprotoHandleInput (proto_env[i], location) == V_TPROTO_QUIT)
quit_status = YES;
break;
}
}
/* If we got a QUIT rule or window event, break out of the loop */
if (quit_status)
break;
/* Update each prototype's dynamics */
for (i = 0; i < MAXWINS; i++)
/* To avoid error messages, we only update if proto_env is valid */
if (proto_env[i])
TprotoUpdate (proto_env[i]);
}
/* Cleanup */
for (i = 0; i < MAXWINS; i++)
{
VOscSelect (screen[i]);
TprotoCleanup (proto_env[i]);
TscClose (screen[i]);
}
TTerminate ();
return EXIT_OK;
}